home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_apache2.idb / usr / freeware / apache2 / include / apr_shm.h.z / apr_shm.h
C/C++ Source or Header  |  2002-07-08  |  6KB  |  164 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2000-2002 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  */
  54.  
  55. #ifndef APR_SHM_H
  56. #define APR_SHM_H
  57.  
  58. #include "apr.h"
  59. #include "apr_pools.h"
  60. #include "apr_errno.h"
  61.  
  62. #ifdef __cplusplus
  63. extern "C" {
  64. #endif /* __cplusplus */
  65.  
  66. /**
  67.  * @file apr_shm.h
  68.  * @brief APR Shared Memory Routines
  69.  */
  70.  
  71. /**
  72.  * @defgroup APR_SHM Shared Memory Routines
  73.  * @ingroup APR
  74.  * @{
  75.  */
  76.  
  77. /**
  78.  * Private, platform-specific data struture representing a shared memory
  79.  * segment.
  80.  */
  81. typedef struct apr_shm_t apr_shm_t;
  82.  
  83. /**
  84.  * Create and make accessable a shared memory segment.
  85.  * @param m The shared memory structure to create.
  86.  * @param reqsize The desired size of the segment.
  87.  * @param file The file to use for shared memory on platforms that
  88.  *        require it.
  89.  * @param pool the pool from which to allocate the shared memory
  90.  *        structure.
  91.  * @remark A note about Anonymous vs. Named shared memory segments:
  92.  *         Not all plaforms support anonymous shared memory segments, but in
  93.  *         some cases it is prefered over other types of shared memory
  94.  *         implementations. Passing a NULL 'file' parameter to this function
  95.  *         will cause the subsystem to use anonymous shared memory segments.
  96.  *         If such a system is not available, APR_ENOTIMPL is returned.
  97.  * @remark A note about allocation sizes:
  98.  *         On some platforms it is necessary to store some metainformation
  99.  *         about the segment within the actual segment. In order to supply
  100.  *         the caller with the requested size it may be necessary for the
  101.  *         implementation to request a slightly greater segment length
  102.  *         from the subsystem. In all cases, the apr_shm_baseaddr_get()
  103.  *         function will return the first usable byte of memory.
  104.  * 
  105.  */
  106. APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
  107.                                          apr_size_t reqsize,
  108.                                          const char *filename,
  109.                                          apr_pool_t *pool);
  110.  
  111. /**
  112.  * Destroy a shared memory segment and associated memory.
  113.  * @param m The shared memory segment structure to destroy.
  114.  */
  115. APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m);
  116.  
  117. /**
  118.  * Attach to a shared memory segment that was created
  119.  * by another process.
  120.  * @param m The shared memory structure to create.
  121.  * @param file The file used to create the original segment.
  122.  *        (This MUST match the original filename.)
  123.  * @param pool the pool from which to allocate the shared memory
  124.  *        structure for this process.
  125.  */
  126. APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
  127.                                          const char *filename,
  128.                                          apr_pool_t *pool);
  129.  
  130. /**
  131.  * Detach from a shared memory segment without destroying it.
  132.  * @param m The shared memory structure representing the segment
  133.  *        to detach from.
  134.  */
  135. APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m);
  136.  
  137. /**
  138.  * Retrieve the base address of the shared memory segment.
  139.  * NOTE: This address is only usable within the callers address
  140.  * space, since this API does not guarantee that other attaching
  141.  * processes will maintain the same address mapping.
  142.  * @param m The shared memory segment from which to retrieve
  143.  *        the base address.
  144.  */
  145. APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m);
  146.  
  147. /**
  148.  * Retrieve the length of a shared memory segment in bytes.
  149.  * @param m The shared memory segment from which to retrieve
  150.  *        the segment length.
  151.  */
  152. APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m);
  153.  
  154. /**
  155.  * Get the pool used by this shared memory segment.
  156.  */
  157. APR_POOL_DECLARE_ACCESSOR(shm);
  158.  
  159. #ifdef __cplusplus
  160. }
  161. #endif
  162.  
  163. #endif  /* APR_SHM_T */
  164.